const fs = require('fs');


let user = { username:"admin11",password:"123455" }


let result = fs.readFileSync('persons.json').toString();
// console.log(result.toString() );
let arr = JSON.parse(result);
// console.log(arr);
var a = arr.findIndex((item) => item.username === user.username)
        a === -1 ? fn() : console.log('用户名已存在')

        function fn() {
            arr.push(user);
            fs.writeFileSync('persons.json',JSON.stringify(arr))
            console.log('注册成功');
        }
